package org.forex.impl.ws;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

import org.forex.api.ws.AbstractHttpCall;
import org.forex.vo.Instrument;

public class GetInstrumentsHistory extends AbstractHttpCall<Instrument> {

	private Map<String, String> parameters;

	public GetInstrumentsHistory() {
		super(Instrument.class);
		parameters=new HashMap<String, String>();
	}

	@Override
	public Map<String, String> getParameters() {
		parameters.put("accountId", "9646994");
		parameters.put("candleFormat", "midpoint");
		//parameters.put("alignmentTimezone", "Europe%2fRome");
		return parameters;
	}

	public Optional<Instrument> get(Instrument instrument) throws IOException{
		parameters.put("instrument", instrument.getInstrument());
		return call("/v1/candles");
	}
	
	public Optional<Instrument> getNumResults(Instrument instrument,int count) throws IOException{
		parameters.put("instrument", instrument.getInstrument());
		parameters.put("count", ""+count);
		return call("/v1/candles");
	}

	@Override
	public String getHttpMethod() {
		return GET;
	}
}
